{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-15T15:12:46.105373Z",
     "start_time": "2020-06-15T15:12:45.265935Z"
    }
   },
   "outputs": [],
   "source": [
    "import torch\n",
    "import numpy as np\n",
    "import sys\n",
    "sys.path.append(\"..\")\n",
    "import d2lzh_pytorch as d2l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-15T15:14:06.087386Z",
     "start_time": "2020-06-15T15:14:06.047773Z"
    }
   },
   "outputs": [],
   "source": [
    "batch_size = 256\n",
    "train_iter,test_iter = d2l.load_data_fashion_mnist(batch_size)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-15T15:30:13.242188Z",
     "start_time": "2020-06-15T15:30:13.238521Z"
    }
   },
   "outputs": [],
   "source": [
    "num_inputs,num_outputs,num_hiddens = 784,10,256"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-15T15:34:10.178466Z",
     "start_time": "2020-06-15T15:34:10.163321Z"
    }
   },
   "outputs": [],
   "source": [
    "W1 = torch.tensor(np.random.normal(0,0.01,(num_inputs,num_hiddens)),dtype=torch.float)\n",
    "b1 = torch.zeros(num_hiddens,dtype=torch.float)\n",
    "W2 = torch.tensor(np.random.normal(0,0.01,(num_hiddens,num_outputs)),dtype=torch.float)\n",
    "b2 = torch.zeros(num_outputs,dtype=torch.float)\n",
    "\n",
    "params = [W1,b1,W2,b2]\n",
    "for param in params:\n",
    "    param.requires_grad_(requires_grad=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-06-15T15:34:50.741171Z",
     "start_time": "2020-06-15T15:34:50.737469Z"
    }
   },
   "outputs": [],
   "source": [
    "def relu(X):\n",
    "    return torch.max(input=X,other=torch.tensor(0,0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.7.5 64-bit ('numpy': virtualenv)",
   "language": "python",
   "name": "python37564bitnumpyvirtualenv325e501f273d447b90cac77d0bfa67d7"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
